public class StackWithMin extends Stack<NodeWithMin>{
  public void push(int value){
    int newMin = Math.min(this.min, value);
    super.push(new NodeWithMin(value, newMin));
  }

  public int getMin(){
    if(this.isEmpty()) return Math.MAX_VALUE;
    else return peek().min;
  }
  }
  
  public class NodeWithMin{
    int value;
    int min;
    
    public NodeWithMin(int value, int min){
      this.value = value;
      this.min = min;
    }
  }